<?php

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('categories-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
$this->_toolbar = array(
		'title'		=>	Yii::t('admin_news', 'Categories Manager'),
		'buttons'	=>	array(
							CHtml::link(Yii::t('admin_news','Advanced Search'), "", array("id"=>"search", "class"=>"search-button button-s")),
		)
);
?>

<div class="search-form">
<?php $this->renderPartial('_search', array(
	'model' => $model,
)); ?>
</div><!-- search-form -->
<?php 
	Yii::app()->clientScript->registerScript('tooltip', "jQuery('a.published_toggle').tooltip();");
	Yii::app()->clientScript->registerScript('tooltip2', "jQuery('.button-column a').tooltip();");
?>
<?php $this->widget('ext.widgets.iGridView', array(
	'id' => 'categories-grid',
	'dataProvider' => $model->search(),
	'afterAjaxUpdate'=>'function(){jQuery("a.status_toggle").tooltip();jQuery(".button-column a").tooltip();}',
	'columns' => array(
		array(
			'name'	=>	'id',
			'htmlOptions'	=>	array(
				'width'	=>	'30',
				'align'	=>	'center'
			)
		),
		array(
			'name'	=>	'title',
			'type'	=>	'raw',
			'value'	=>	'CHtml::link($data->title_tree,array("categories/update","id"=>$data->id), array("style"=>"text-decoration:none"))',
		),
		'alias',
		array(
			'name'	=>	'parent_id',
			'value'	=>	'($data->parent_id>0)?Categories::model()->findByPk($data->parent_id)->title:""'
		),
		array(
			'header'	=>Yii::t('app','News Count'),
			'type'=>'raw',
			'value'=>'$data->newsCount',
			'htmlOptions'	=>	array(
				'width'	=>	'100',
				'align'	=>	'center',
			),
		),
		array(
			'name'	=>	'ordering',
			'htmlOptions'=>array(
				'width'	=>	60,
				'align'	=>	'center'
			)
		),
		/*
		'created_by',
		'modified',
		'modified_by',
		*/
		array(
            'class'=>'JToggleColumn',
            'name'=>'published', // boolean model attribute (tinyint(1) with values 0 or 1)
            'htmlOptions'=>array('style'=>'text-align:center;min-width:60px;'),
        ),
		array(
			'class' => 'CButtonColumn',
			'afterDelete'=>'function(link,success,data){if(data!="") alert(data); }'
		),
	),
)); ?>